package com.yanfan.zutai.service.impl;

import cn.hutool.core.lang.Snowflake;
import cn.hutool.core.util.IdUtil;
import com.yanfan.common.utils.DateUtils;
import com.yanfan.zutai.domain.BDeviceWarn;
import com.yanfan.zutai.mapper.BDeviceWarnMapper;
import com.yanfan.zutai.service.IBDeviceWarnService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


/**
 * 设备报警Service业务层处理
 *
 * @author ruoyi
 * @date 2021-02-27
 */
@Service
public class BDeviceWarnServiceImpl implements IBDeviceWarnService {
    @Autowired
    private BDeviceWarnMapper bDeviceWarnMapper;

    /**
     * 查询设备报警
     *
     * @param id 设备报警ID
     * @return 设备报警
     */
    @Override
    public BDeviceWarn selectBDeviceWarnById(Long id) {
        return bDeviceWarnMapper.selectBDeviceWarnById(id);
    }

    /**
     * 查询设备报警列表
     *
     * @param bDeviceWarn 设备报警
     * @return 设备报警
     */
    @Override
    public List<BDeviceWarn> selectBDeviceWarnList(BDeviceWarn bDeviceWarn) {
        return bDeviceWarnMapper.selectBDeviceWarnList(bDeviceWarn);
    }

    /**
     * 新增设备报警
     *
     * @param bDeviceWarn 设备报警
     * @return 结果
     */
    @Override
    public int insertBDeviceWarn(BDeviceWarn bDeviceWarn) {
        Snowflake snowflake = IdUtil.getSnowflake(6, 2);
        long id = snowflake.nextId();
        bDeviceWarn.setId(id);
        return bDeviceWarnMapper.insertBDeviceWarn(bDeviceWarn);
    }

    /**
     * 修改设备报警
     *
     * @param bDeviceWarn 设备报警
     * @return 结果
     */
    @Override
    public int updateBDeviceWarn(BDeviceWarn bDeviceWarn) {
        bDeviceWarn.setUpdateTime(DateUtils.getNowDate());
        return bDeviceWarnMapper.updateBDeviceWarn(bDeviceWarn);
    }

    /**
     * 批量删除设备报警
     *
     * @param ids 需要删除的设备报警ID
     * @return 结果
     */
    @Override
    public int deleteBDeviceWarnByIds(Long[] ids) {
        return bDeviceWarnMapper.deleteBDeviceWarnByIds(ids);
    }

    /**
     * 删除设备报警信息
     *
     * @param id 设备报警ID
     * @return 结果
     */
    @Override
    public int deleteBDeviceWarnById(Long id) {
        return bDeviceWarnMapper.deleteBDeviceWarnById(id);
    }
}
